package com.xiaoshuidi.cloud.framework.filings.core.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 装修程度
 * @Author Feng
 * @date 2023/5/5
 */
@Getter
@AllArgsConstructor
public enum DecorationLevelEnum {

    ROUGH(1,"毛坯"),
    SIMPLE(2, "简装"),
    MEDIUM(3, "中装"),
    FINE_DECORATION(5, "精装"),
    LUXURY_DECORATION(6, "豪装");
    private int code;
    private String name;

    public static Integer getCodeByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        Optional<DecorationLevelEnum> find = Arrays.stream(DecorationLevelEnum.values()).filter(s -> s.getName().equals(name)).findFirst();
        if (find.isPresent()) {
            return find.get().getCode();
        }
        return null;
    }
}
